<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
    <style>
      * {
        margin: 0;
        padding: 0;
      }
      ul , ol{
        width: 300px;
        height: 50px;
        display: flex;
        justify-content: space-between;
      }
      li {
        list-style: none;
        width: 50px;
        height: 50px;
        border-radius: 50%;
        background-color: yellowgreen;
        display: flex;
        justify-content: center;
        align-items: center;
      }
    </style>
  </head>
  <body>
    <ul>
      <li>1</li>
      <li>2</li>
      <li>3</li>
      <li>4</li>
      <li>5</li>
    </ul>
    <ol>
        <li>o1</li>
        <li>o2</li>
        <li>o3</li>
        <li>o4</li>
        <li>o5</li>
      </ol>
    <script>
      let li = document.querySelectorAll("li");
      li.forEach((item) => {
        item.onclick = dom2;
      });

      function dom2() {
        //    this 自身
        // 在函数中this指向函数的调用者
        console.log(this.parentNode.children);
        for (let item of this.parentNode.children) {
          item.style.backgroundColor = "yellowgreen";
        }
        this.style.backgroundColor = "red";
      }
    </script>
  </body>
</html>
